<!--#include file="Config.asp"-->
<!--#include file="emp_is.asp"-->
<!--#include file="Header.asp"-->
<script language=Javascript>
//批量选择选项
function check_all(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
    }
  }
</script>
<%
'代码作者：54IT.COM
'联系：34989180@qq.com

TimeType=Trim(request("TimeType"))
If timetype="" Then
timetype=1
Else
TimeType=Trim(request("TimeType"))
End if
pmcount=request("PerPageCount")   '每页记录数
if pmcount="" or isempty(pmcount) or pmcount<1 then
       pmcount=page_num_max_per*2 '每页记录数
end If

Dep_ID=int(request("Dep_ID"))   '部门ID
If Dep_ID="" Then
Dep_ID=int(session("Dep_ID"))
End If

'时间段判断
if request("start_time")<>"" then
start_time=request("start_time")
else
start_time=date()-30
end if

if request("end_time")<>"" then
end_time=request("end_time")
else
end_time=date()+3
end if

if request("CRM_ID")="" then
CRM_ID=0
Else
CRM_ID=Trim(request("CRM_ID"))
end If

if trim(request("AssetName"))<>"" then
AssetName=Trim(request("AssetName"))
end If

if request("BrandID")="" then
BrandID=0
Else
BrandID=Trim(request("BrandID"))
end If

if request("SKUID")="" or len(request("SKUID"))<9 then
SKUID=0
Else
SKUID=Trim(request("SKUID"))
end If

if request("StockType")="" then
StockType=0
Else
StockType=Trim(request("StockType"))
end If

if request("AssetState")="" then
AssetState=0
Else
AssetState=Trim(request("AssetState"))
end If

if request("AssetFrom")="" then
AssetFrom=0
Else
AssetFrom=Trim(request("AssetFrom"))
end If


'--------------------------------数据输入HTML部分
%>

<table class="table table-condensed table-hover table-striped table-bordered">
<FORM METHOD=POST ACTION="?">
<TR>
<Th>
名称：<input type="text" name="AssetName" size='10' value='<%=trim(request("AssetName"))%>'>
SKU：<input type="text" name="SKUID" size='10' value='<%=trim(request("SKUID"))%>'>
<!--  显示相关客户 -->
<select name="CRM_ID"  >
<option value="0" >=供应商=</option>
<%
	sql_s= "select distinct ID,name from CRM_List order by ID desc"
	rss.open sql_s,conn,1,1
	if not rss.eof then
	 for i=1 to rss.recordcount
%>
<option value="<%=int(rss("ID"))%>" <%If Int(rss("ID"))=Int(CRM_ID) Then %>selected<%End if%>><%=int(rss("ID"))%>.<%=rss("name")%></option>
<%
rss.movenext
next
end If
rss.close
%>
</select>
<!-- 品牌:   -->
<SELECT NAME="BrandID">
<option value="0">＝全品牌＝</option>
<%
	sql_s= "select distinct id,name from basic_brand order by id "
	rss.open sql_s,conn,1,1
	if not rss.eof then
	 for i=1 to rss.recordcount
%>
<option value="<%=int(rss("id"))%>" <%If Int(rss("id"))=Int(BrandID) Then %>selected<%End if%>><%=int(rss("id"))%>.<%=rss("name")%></option>
<%
rss.movenext
next
end if
set rss=nothing
%>
</SELECT>
<SELECT NAME="StockType">
<option value="0">＝全分类＝</option>
<%
	set rss= server.createobject("adodb.recordset")
	sql_s= "select distinct type_id,type_name,type_fatherid from cmdb_type where type_fatherid<>0 and type_Isshow=1 order by type_fatherid,type_id"
	rss.open sql_s,conn,1,1
	if not rss.eof then
	 for i=1 to rss.recordcount
%>
<option value="<%=int(rss("type_id"))%>" <%If Int(rss("type_id"))=Int(StockType) Then %>selected<%End if%>> <%=int(rss("type_id"))%>.<%=rss("type_name")%></option>
<%
rss.movenext
next
end if
set rss=nothing
%>
</SELECT>
<SELECT NAME="AssetFrom">
<option value="0">＝来源＝</option>
<%
	set rss= server.createobject("adodb.recordset")
	sql_s= "select id,name from CMDB_from order by id "
	rss.open sql_s,conn,1,1
	if not rss.eof then
	 for i=1 to rss.recordcount
%>
<option value="<%=int(rss("id"))%>" <%If int(rss("id"))=AssetFrom Then %>selected<%End if%>> <%=rss("name")%></option>
<%
rss.movenext
next
end if
set rss=nothing
%>
</SELECT>
<SELECT NAME="AssetState">
<option value="0">＝状态＝</option>
<%
	set rss= server.createobject("adodb.recordset")
	sql_s= "select id,name from CMDB_state  order by id"
	' id=2 使用中 7 已经领用 113 采购中
	rss.open sql_s,conn,1,1
	if not rss.eof then
	 for i=1 to rss.recordcount
%>
<option value="<%=int(rss("id"))%>" <%If Int(rss("id"))=Int(AssetState) Then %>selected<%End if%>> <%=rss("name")%></option>
<%
rss.movenext
next
end if
rss.close
%>
</SELECT>
<!-- 部门   -->
<SELECT NAME="Dep_ID" >
<option value="0">＝全部部门＝</option>

<%
rss.open "select * from basic_company order by CompanyID",conn,1,1
for c=1 to rss.recordcount
%>
<optgroup label="<%=trim(rss("ComOrder"))%>.<%=trim(rss("Company"))%>">
<%
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "select Dep_ID,Dep_name,Dep_order from emp_dep where Dep_isshow=1 and CompanyID="&int(rss("CompanyID"))&" order by Dep_order",conn,1,1
for d=1 to rs.recordcount
%>
<option value="<%=int(rs("Dep_ID"))%>"><%=trim(rss("ComOrder"))%>.<%=trim(rs("Dep_order"))%>.<%=trim(rs("Dep_name"))%></option><%
rs.movenext
next
rs.close


rss.movenext
next
rss.close

%>
</SELECT>
<BR>

从：<INPUT TYPE="text" NAME="start_time" value='<%=start_time%>' size='9'>
到：<INPUT TYPE="text" NAME="End_Time" value='<%=End_Time%>' size='9'>
<input type="radio" name="TimeType" value='0' <%If timetype=0 then%>checked<%End if%>>时间段
<input type="radio" name="TimeType" value='1' <%If timetype=1 then%>checked<%End if%>>所有时间
<INPUT TYPE="submit"value="查询">
</th>
</TR>
</FORM>
</table>

<!---------明细数据HTML部分开始 ----------------------------------->
<%

sql_list= "select * from CMDB_List where 1=1 "

if not (CRM_ID=0 or isempty(CRM_ID) ) then
	sql_list=sql_list&" and CRM_ID="&CRM_ID&" "
end If

if Dep_ID<>0 Then
	sql_list=sql_list&" and Dep_ID="&Dep_ID
end If

if trim(request("AssetName"))<>"" Then
	sql_list=sql_list&" and name like '%"&AssetName&"%' "
end If

if not (SKUID=0 or isempty(SKUID) ) then
	sql_list=sql_list&" and SKUID="&SKUID&" "
end If

if not (BrandID=0 or isempty(BrandID) ) then
	sql_list=sql_list&" and BrandID="&BrandID&" "
end If

if not (StockType=0 or isempty(StockType) ) then
	sql_list=sql_list&" and StockType="&StockType&" "
end If
if not (AssetState=0 or isempty(AssetState) ) then
	sql_list=sql_list&" and AssetState="&AssetState
end If
if not (AssetFrom=0 or isempty(AssetFrom) ) then
	sql_list=sql_list&" and AssetFrom="&AssetFrom&" "
end If

If timetype=0 Then '区分是否选择时间段内查询，默认选择
sql_list=sql_list&" and intime between "&start_time&" and "&end_time&" "
End If


sql_list=sql_list&" order by SKUID desc"
rs.open sql_list,conn,1,1

rs.pagesize=pmcount   	'设置每页数
mpage=rs.pagecount    	'得到总页数
pageno=request("pageno")    '当前页码
totalnum=rs.recordcount
if len(pageno)=0 or int(pageno)<1 or int(pageno)>mpage then
	pageno=1
end if
%>

<table class="table table-condensed table-hover table-striped table-bordered">
<TR bgcolor='#ddeeff'>
	<TH><!-- 选择 --></TH>
	<TH>SKUID</TH>
	<TH>名称</TH>
	<TH>价格/登记时间</TH>
	<TH>管理</TH>
	<TH>备注</TH>
</TR>
<form method="post" name="fm1" action="BarCodePrint.asp" target="_blank">
<%
if not (rs.eof or err) then
rs.absolutepage=pageno	'将指针移至指定页的第一条记录
loopno=pmcount
PayTatol=0
do while not (rs.eof or err) and loopno>0
%>

<TR style="cursor:hand" onmouseover="this.bgColor='#f6f6f6';" onmouseout="this.bgColor='#ffffff';" title='<%=int(Trim(rs("SKUID")))&Trim(GetSkuUser(rs("SKUID")))&Trim(rs("info"))%>''>
<TD><INPUT TYPE="checkbox" NAME="SKUID" value='<%=int(Trim(rs("SKUID")))%>'  checked></TD>
<TD><A HREF="CMDB_View.asp?SKUID=<%=int(Trim(rs("SKUID")))%>" title='编辑SKU所有日志记录' target="_blank"><%=int(Trim(rs("SKUID")))%></A></TD>
<TD><A HREF="CMDB_View.asp?SKUID=<%=int(Trim(rs("SKUID")))%>" title='编辑SKU所有日志记录' target="_blank"><%=Trim(GetCMDBType(rs("Stocktype")))%>.<%=Trim(GetBrand(rs("BrandID")))%>.<%=Trim(rs("name"))%></A></TD>
<TD><B><%=FormatCurrency(rs("sku_price"),,true)%></B>-<%=FormatDateTime(rs("intime"),2)%></TD>
<TD><%=Left(Trim(GetCRMName(rs("CRM_ID"))),4)%>.<%=Left(GetDepName(rs("Dep_ID")),4)%><%=Trim(GetSkuUser(rs("SKUID")))%><%=Trim(showSkuWhere(rs("SKUID")))%><%=Trim(GetCMDBState(rs("AssetState")))%>

<%
'部门资产管理员修改权限
if IsValidate=1 then
%>
<A HREF="AssetLogDetailUserEdit.asp?SKUID=<%=rs("SKUID")%>" target="_blank"><FONT COLOR="#CC0000">改责任人</FONT></A>
<%
End if%>

</TD>
<TD><%=Left(Trim(rs("info")),10)%>..</TD>
</TR>
<%
PayTatol=PayTatol+rs("sku_price")
rs.movenext
loopno=loopno-1
loop
rs.close
set rs=nothing
%>
</table>
<!-- 翻页------------------------------- -->
<table class="table table-condensed table-hover table-striped table-bordered">
<TR bgcolor='#ddeeff' >
	<TD><input type="checkbox" name="chkall" value="on" checked onClick="check_all(this.form)">
	<FONT COLOR="#CC0000"><U><B>全选</B></U></FONT></TD>
	<TD>
<SELECT NAME="PrintType">
	<OPTION VALUE="1" SELECTED>IT资产标签（大尺寸）</option>
	<OPTION VALUE="2">IT服务与故障申报标签（小尺寸）</option>
</SELECT>
<input type="submit" value='  >> 打印预览所选 '></TD>

	<TD align='right'>
	合计：<%=totalnum%>
	金额合计：<B><%=FormatCurrency(PayTatol,,true)%></B>
<%IF pageno<>1 then%>
<A HREF="?pageno=1&AssetState=<%=AssetState%>&CRM_ID=<%=CRM_ID%>&BrandID=<%=BrandID%>&StockType=<%=StockType%>&start_time=<%=start_time%>&end_time=<%=end_time%>&TimeType=<%=TimeType%>&Dep_ID=<%=Dep_ID%>&AssetName=<%=AssetName%>&SKUID=<%=SKUID%>">
[首页]</A>
<%
End If
%>
<%IF pageno>1 then%>
<A HREF="?pageno=<%=pageno-1%>&AssetState=<%=AssetState%>&CRM_ID=<%=CRM_ID%>&BrandID=<%=BrandID%>&StockType=<%=StockType%>&start_time=<%=start_time%>&end_time=<%=end_time%>&TimeType=<%=TimeType%>&Dep_ID=<%=Dep_ID%>&AssetName=<%=AssetName%>&SKUID=<%=SKUID%>">
[上一页]</A>
<%
End if
IF pageno<>mpage then
%>
<A HREF="?pageno=<%=pageno+1%>&AssetState=<%=AssetState%>&CRM_ID=<%=CRM_ID%>&BrandID=<%=BrandID%>&StockType=<%=StockType%>&start_time=<%=start_time%>&end_time=<%=end_time%>&TimeType=<%=TimeType%>&Dep_ID=<%=Dep_ID%>&AssetName=<%=AssetName%>&SKUID=<%=SKUID%>">
[下一页]</A>
<%
End if
%>
<%IF pageno<>mpage then%>
<A HREF="?pageno=<%=mpage%>&AssetState=<%=AssetState%>&CRM_ID=<%=CRM_ID%>&BrandID=<%=BrandID%>&StockType=<%=StockType%>&start_time=<%=start_time%>&end_time=<%=end_time%>&TimeType=<%=TimeType%>&Dep_ID=<%=Dep_ID%>&AssetName=<%=AssetName%>&SKUID=<%=SKUID%>">
[末页]</A>
<%
End If
%>
[第<%=pageno%>页/共<%=mpage%>页]
</TD>
</TR>
</form>
</TABLE>

<!-- 翻页-- -->
<!-- ----------结束 -->
<%
end if
%>
</TD>
</TR>
</TABLE>
<!--#include file="Footer.asp" -->